package letcode209

func MinSubArrayLen(target int, nums []int) int {
	left, s := 0, 0
	ans := len(nums) + 1
	for right, value := range nums {
		s += value
		for (s - nums[left]) >= target {
			s -= nums[left]
			left++
		}
		if s >= target {
			ans = min(ans, right-left+1)
		}
	}
	return ans
}
